#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>

class ChoppedStick
{
public:
	ChoppedStick(unsigned stick_length): length_(stick_length), is_taked_(false) {}

	inline bool is_taked() const { return is_taked_; }
	inline void take(bool value = true) { is_taked_ = value; }

	inline unsigned length() const { return length_; }

private:
	unsigned length_;
	bool is_taked_;
};

bool LargerStick(const ChoppedStick& lhs, const ChoppedStick& rhs)
{
	return lhs.length() > rhs.length();
}

bool OtherStickTraversal(std::vector<ChoppedStick>& chopped_sticks,
	const unsigned assumed_length,
	unsigned need_fix_num,
	unsigned length_now,
	unsigned searching_index)
{
	bool answer_gotten = false;

	if (length_now == assumed_length)
	{
		if (--need_fix_num == 1)
			return true;
		
		unsigned i;
		for (i = 1; i < chopped_sticks.size(); ++i)
			if (!chopped_sticks[i].is_taked())
				break;

		chopped_sticks[i].take();
		answer_gotten = OtherStickTraversal(chopped_sticks, assumed_length, need_fix_num, chopped_sticks[i].length(), i);
		chopped_sticks[i].take(false);

		return answer_gotten;
	}

	for (unsigned i = searching_index + 1; i < chopped_sticks.size() && !answer_gotten; ++i)
	{
		if (chopped_sticks[i].is_taked() ||
			length_now + chopped_sticks[i].length() > assumed_length)
		{
			continue;
		}
		
		chopped_sticks[i].take();

		answer_gotten = OtherStickTraversal(chopped_sticks,
			assumed_length,
			need_fix_num,
			length_now + chopped_sticks[i].length(),
			i);
		
		chopped_sticks[i].take(false);

		while (i < chopped_sticks.size() &&
			chopped_sticks[i + 1].length() == chopped_sticks[i].length())
			++i;
	}
	return answer_gotten;
}

unsigned SearchMinimalLength(std::vector<ChoppedStick>& chopped_sticks, unsigned length_sum)
{
	std::sort(chopped_sticks.begin(), chopped_sticks.end(), LargerStick);

	unsigned assumed_length = chopped_sticks.front().length();

	chopped_sticks.front().take();

	for (bool answer_gotten = false; assumed_length != length_sum; ++ assumed_length)
	{
		if (length_sum % assumed_length)
			continue;
		
		answer_gotten = OtherStickTraversal(chopped_sticks,
			assumed_length,
			length_sum / assumed_length,
			chopped_sticks.front().length(), 0);
		
		if (answer_gotten)
			break;
	}

	return assumed_length;
}

int main()
{
	unsigned size;
	unsigned stick_length;
	unsigned length_sum = 0;

	std::cin >> size;

	std::vector<ChoppedStick> chopped_sticks;

	while (size--)
	{
		std::cin >> stick_length;
		chopped_sticks.push_back(ChoppedStick(stick_length));
		length_sum += stick_length;
	}

	unsigned min_length = SearchMinimalLength(chopped_sticks, length_sum);
	
	std::cout << min_length;

	return 0;
}